Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial sys_config implementation #5781

Merged
merged 1 commit into from Jul 21, 2019
Merged

Conversation

ruipin
Copy link
Contributor

@ruipin ruipin commented Apr 1, 2019

This PR contains a mostly-complete implementation of the sys_config syscalls, which is one of the many things required for RPCS3 to be able to boot vsh standalone. In particular, without sys_config, vsh believes no controllers are connected, and as such does not recognize any input.

Below I have copied in an explanation of how sys_config works (also included at the top of sys_config.h):

sys_config is a "subscription-based data storage API"

It has the concept of services and listeners. Services provide data, listeners subscribe to registration/unregistration events from specific services.

Services are divided into two classes: LV2 services (positive service IDs) and User services (negative service IDs).
LV2 services seem to be implictly "available", probably constructed on-demand with internal LV2 code generating the data. An example is PadManager (service ID 0x11).
User services may be registered through a syscall, and have negative IDs. An example is libPad (service ID 0x8000'0000'0000'0001).
Note that user-mode *cannot* register positive service IDs.

To start with, you have to get a sys_config handle by calling sys_config_open and providing an event queue.
This event queue will be used for sys_config notifications if a subscribed config event is registered.

With a sys_config handle, listeners can be added to specific services using sys_config_add_service_listener.
This syscall returns a service listener handle, which can be used to close the listener and stop further notifications.
Once subscribed, any matching past service registrations will be automatically sent to the supplied queue (thus the "data storage").

Services exist "implicitly", and data may be registered *onto* a service by calling sys_config_register_service.
You can remove config events by calling sys_config_unregister_service and providing the handle returned when registering a service.

If a service is registered (or unregistered) and matches any active listener, that listener will get an event sent to the event queue provided in the call to sys_config_open.

This event will contain the type of config event ("service event" or "IO event", in event.source),
the corresponding sys_config handle (event.data1), the config event ID (event.data2 & 0xffff'ffff),
whether the service was registered or unregistered ('data2 >> 32'), and what buffer size will be needed to read the corresponding service event (event.data3).

NOTE: if multiple listeners exist, each gets a separate event ID even though all events are the same!

After receiving such an event from the event queue, the user should allocate enough buffer and call sys_config_get_service_event
(or sys_config_io_event) with the given event ID, in order to obtain a sys_config_service_event_t (or sys_config_io_event_t) structure
with the contents of the service that was (un)registered.

vsh uses sys_config as a way to permanently store system settings and hardware configuration, e.g. how many controllers are connected.

This PR implements all the service event functionality except for the listener filtering by buffer, as that piece of the code is extremely difficult to reverse engineer. In addition, as I have never seen vsh use it, I also only stub the IO error related syscalls, however I believe their implementation is extremely similar to the rest of sys_config.

In addition, once sys_config is initialized the first time it will enqueue the LV2 Padmanager event that tells vsh that a controller is connected. The contents of this event's buffer are also not fully understood as of this moment. The current implementation of sys_config is flexible enough that it should be straightforward to implement further LV2 services as soon as they are understood.


PS: I do not believe this PR affects any game. It is extremely vsh-specific.

rpcs3/Emu/Cell/lv2/sys_config.h Outdated Show resolved Hide resolved
rpcs3/Emu/Cell/lv2/sys_config.h Show resolved Hide resolved
rpcs3/Emu/Cell/lv2/sys_config.h Show resolved Hide resolved
rpcs3/Emu/Cell/lv2/sys_config.cpp Outdated Show resolved Hide resolved
rpcs3/Emu/Cell/lv2/sys_config.cpp Outdated Show resolved Hide resolved
@ruipin ruipin force-pushed the vsh-sysconfig branch 2 times, most recently from 23332e0 to 1825dff Compare April 2, 2019 19:06
rpcs3/Emu/Cell/lv2/sys_config.cpp Outdated Show resolved Hide resolved
rpcs3/Emu/Cell/lv2/sys_config.cpp Outdated Show resolved Hide resolved
rpcs3/Emu/Cell/lv2/sys_config.cpp Outdated Show resolved Hide resolved
SYS_CONFIG_SERVICE_0x20 = 0x20,
SYS_CONFIG_SERVICE_0x30 = 0x30,

SYS_CONFIG_SERVICE_USER_BASE = static_cast<s64>(0x8000'0000'0000'0000llu),
Copy link
Contributor

@elad335 elad335 May 2, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use INT64_C macro. (int64 constant)

Suggested change
SYS_CONFIG_SERVICE_USER_BASE = static_cast<s64>(0x8000'0000'0000'0000llu),
SYS_CONFIG_SERVICE_USER_BASE = INT64_C(0x8000'0000'0000'0000),

Copy link
Contributor Author

@ruipin ruipin Jul 21, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs the static_cast. I've replaced the llu with UINT64_C, though.

@ruipin
Copy link
Contributor Author

ruipin commented Jul 21, 2019

I've rebased this, and went through the remaining reviews.

@Nekotekina Nekotekina merged commit 070c3af into RPCS3:master Jul 21, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants